﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace UI
{
    public partial class Cover : Form
    {
        public int ShowTime { get; set; }
        double t = 0.05;
        public Cover()
        {
            InitializeComponent();
            ShowTime = 2;
        }

        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);
            ShowWindow();
        }

        public void ShowWindow()
        {
            this.timer1.Enabled = true;
            timer2.Interval = ShowTime * 1000;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (t > 0)
            {
                if (this.Opacity < 1)
                {
                    this.Opacity += t;
                }
                else
                {
                    this.Enabled = false;
                    timer2.Enabled = true;
                }
            }
            else
            {
                if (this.Opacity > 0)
                {
                    this.Opacity += t;
                }
                else
                {
                    timer1.Enabled = false;
                    this.Close();
                }
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            t = -0.1;
            this.Enabled = true;
        }
    }
}
